
//
//  MyTableViewCell.m
//  afn
//
//  Created by mac on 2018/5/9.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "MyTableViewCell.h"
#import "UserViewController.h"
#import "CollectionViewController.h"
@implementation MyTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)creatView{
    UIImageView *imageview=[UIImageView new];
    [self addSubview:imageview];
    [imageview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    imageview.image=[UIImage imageNamed:@"bg_bengjing"];
    
    
    UIView *beiJingView=[UIView new];
    [self addSubview:beiJingView];
    [beiJingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.bottom.mas_equalTo(-20);
        make.height.mas_equalTo(70);
    }];
    beiJingView.layer.cornerRadius=5;
    beiJingView.backgroundColor=[UIColor whiteColor];
    UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushTopUserView:)];
    [beiJingView addGestureRecognizer:tapGesture2];
    
    UIImageView *userIamge=[UIImageView new];
    [beiJingView addSubview:userIamge];
    [userIamge mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(7);
        make.width.height.mas_equalTo(50);
        make.centerY.mas_equalTo(0);
    }];
    userIamge.layer.cornerRadius=25;
    userIamge.layer.masksToBounds=YES;
    NSString *url=_useerModel.image_path;
    [userIamge sd_setImageWithURL:[NSURL URLWithString:url]];
    if (userIamge.image==nil) {
        userIamge.image=[UIImage imageNamed:@"pho_touxiang"];
    }
    
    UILabel *label=[UILabel new];
    [beiJingView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(userIamge.mas_centerY).mas_equalTo(-4);
        make.left.mas_equalTo(userIamge.mas_right).mas_equalTo(10);
        make.right.mas_equalTo(-60);
    }];
    label.text=_useerModel.nickname;
    label.textColor=ColorWithRGB(99, 99, 99);
    label.font=[UIFont systemFontOfSize:14];
    
    UILabel *label2=[UILabel new];
    [beiJingView addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(label);
        make.top.mas_equalTo(label.mas_bottom).mas_equalTo(8);
    }];
    label2.text=@"个人信息";
    label2.font=[UIFont systemFontOfSize:14];
    label2.textColor=ColorWithRGB(99, 99, 99);
    [label2 layoutIfNeeded];
    
    UIImageView *xinXiImage=[UIImageView new];
    [beiJingView addSubview:xinXiImage];
    [xinXiImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(label2.mas_right).mas_equalTo(4);
        make.centerY.mas_equalTo(label2);
        make.width.height.mas_equalTo(16);
    }];
    xinXiImage.image=[UIImage imageNamed:@"icon_gerenxinxi"];
    
}
-(void)creatView2{
    self.backgroundColor=[UIColor whiteColor];
    NSArray *arr1=[NSArray arrayWithObjects:@"我的收藏",@"我的评论",@"我的钱包",@"我的优惠券", nil];
    NSArray *arr2=[NSArray arrayWithObjects:@"icon_shoucang",@"mypji",@"icon_tuiguang",@"icon_youhuiquan", nil];
    for (int i=0; i<4; i++) {
        UIView *beijiview=[UIView new];
        [self addSubview:beijiview];
        [beijiview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(0);
            make.height.mas_equalTo(50);
            make.top.mas_equalTo(51*i);
        }];
        beijiview.userInteractionEnabled=YES;
        beijiview.tag=i;
        UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToMoerViewController:)];
        [beijiview addGestureRecognizer:tapGesture2];
        if (i!=3) {
            UIView *xianView=[UIView new];
            [self addSubview:xianView];
            [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(10);
                make.right.mas_equalTo(-10);
                make.height.mas_equalTo(1);
                make.top.mas_equalTo(beijiview.mas_bottom);
            }];
            xianView.backgroundColor=_LightGrey;
        }
        
        UIButton *btn=[UIButton new];
        [beijiview addSubview:btn];
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(10);
            make.width.mas_equalTo(20);
            make.top.bottom.mas_equalTo(0);
        }];
        [btn setImage:[UIImage imageNamed:arr2[i]] forState:0];
        
        UILabel *label=[UILabel new];
        [beijiview addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(btn.mas_right).mas_equalTo(10);
            make.centerY.mas_equalTo(0);
        }];
        label.text=arr1[i];
        label.font=[UIFont systemFontOfSize:14];
        label.textColor=ColorWithRGB(49, 49, 49);
        
        UIImageView *jianTouimage=[UIImageView new];
        [beijiview addSubview:jianTouimage];
        [jianTouimage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-10);
            make.centerY.mas_equalTo(0);
            make.width.mas_equalTo(9);
            make.height.mas_equalTo(18/4*3);
        }];
        jianTouimage.image=[UIImage imageNamed:@"arrow_right_black"];
    }
   
}
-(void)pushTopUserView:(UITapGestureRecognizer *)tap{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *token= [defaults objectForKey:@"token"];
    if ([gongju charIsNil:token]) {
        [gongju ToLoging:self.viewController];
        return;
    }

    UserViewController *user=[UserViewController new];
    [gongju pushNextViewController:self.viewController andRootController:user];
}
-(void)pushToMoerViewController:(UITapGestureRecognizer *)tap{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *token= [defaults objectForKey:@"token"];
    if ([gongju charIsNil:token]) {
        [gongju ToLoging:self.viewController];
        return;
    }
    if (tap.view.tag==0) {
        CollectionViewController *collerction=[[CollectionViewController alloc] init];
        [gongju pushNextViewController:self.viewController andRootController:collerction];
    }
}
   
@end
